<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>增加用户</title>
    <script type="text/javascript">
    	function checkData(){
    		var name=document.getElementById("cname1").value;
    		var phone=document.getElementById("cphone1").value;
    		var email=document.getElementById("cemail1").value;
    		var cmpname=document.getElementById("cmpname1").value;
    		if(name.length==0){
    			alert("请填写客户名称！");
    			return false;
    		}
    		if(phone.length==0){
    			alert("请填写客户电话号码！");
    			return false;
    		}
    		var re=/^1\d{10}$/;
    		if(!re.test(phone)){
    			alert("电话号码必须由11位数字组成,并且第一位为1！");
    			return false;
    		}
    		var re2=/^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
    		if(email.length==0){
    			alert("未填写邮箱！");
    			return false;
    		}
    		if(!re2.test(email)){
    			alert("邮箱格式不对,例：129248@qq.com!");
    			return false;
    		}
    		if(cmpname.length==0){
    			alert("未填写公司名称!");
    			return false;
    		}
    		return true;
    	}
    	function back(){
    		var url='${pageContext.request.contextPath }/customer.action?method=queryCustomer';
    		window.location.href=url;
    	}
    </script>
    <style type="text/css">
    body {
				background-image:
				url(${pageContext.request.contextPath}/images/forum7.jpg);
			}
    </style>
  </head>
  
  <body>
  	<form onsubmit="return checkData();" action="${pageContext.request.contextPath}/customer.action?method=updateCustomer" method="post">
   		<center><h2>修改客户信息</h2></center>
   		<div style="display:none;">
   			<input type="text" name="cid1" id="cid1" value="${requestScope.customer.cusId }"/>
   		</div>
   		<table border="0px" align="center">
   			<tr>
   				<td align="right">客户姓名：</td>
   				<td align="left"><input type="text" name="cname1" id="cname1" value="${requestScope.customer.cusName }"/></td>
   			</tr>
   			<tr>
   				<td align="right">电话号码：</td>
   				<td align="left"><input type="text" name="cphone1" id="cphone1" value="${requestScope.customer.cusPhone }"/></td>
   			</tr>
   			<tr>
   				<td align="right">email：</td>
   				<td align="left"><input type="text" name="cemail1" id="cemail1" value="${requestScope.customer.cusEmail }"/></td>
   			</tr>
   			<tr>
   				<td align="right">公司名称：</td>
   				<td align="left"><input type="text" name="cmpname1" id="cmpname1" value="${requestScope.customer.companyName }"/></td>
   			</tr>
   			<tr>
   				<td align="center"><input type="submit" value="保存"/></td>
   				<td align="center"><input type="reset" value="重置"/></td>
   			</tr>
   		</table>
   		<center><a href="#" onClick="back();">返回</a></center>
   	</form>
  </body>
</html>
